<?php

/**
 * PENGUIN FrameWork
 * View
 * Add module resource into FW
 * 
 * @author      hungtd <tdhungit@gmail.com> 0972014011
 * @copyright   Tran Dinh Hung 2011
 * @package     PenguinFW
 * @subpackage  ModuleBuilder
 * @version     1.0.0
 */
?>

<?=form_open('module_builder/index');?>
<div class="md-error">
    <?=validation_errors();?>    
</div>
<table class="mb">
    <tr>
        <td width="220px;"><?=lang('Model name [module=model+s]');?></td>
        <td><input type="text" name="module" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Module resource name');?></td>
        <td><input type="text" name="module_resource" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Module resource Main name');?></td>
        <td><input type="text" name="module_resource_main" /></td>
    </tr>
    
    <tr>
        <td><?=lang('User name');?></td>
        <td><input type="text" name="username" /></td>
    </tr>
    
    <tr>
        <td><?=lang('New module');?></td>
        <td><input type="checkbox" name="new_module" value="1" checked="checked" /></td>
    </tr>
    
    <tr>
        <td><?=lang('New resource');?></td>
        <td><input type="checkbox" name="new_resource" value="1" checked="checked" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Create table');?></td>
        <td><input type="checkbox" name="create_table" value="1" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Insert menu');?></td>
        <td><input type="checkbox" name="insert_menu" value="1" checked="checked" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Menu link');?></td>
        <td><input type="text" name="menu_link" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Insert field');?></td>
        <td><input type="checkbox" name="insert_field" value="1" checked="checked" /></td>
    </tr>
    
    <tr>
        <td><?=lang('Field name');?></td>
        <td>
            <div id="mb-content-field">
                <div class="mb-field"><input type="text" name="field_name[]" /></div>
            </div>
            <div class="md-b"><input type="button" value="<?=lang('Add field');?>" id="mb-add-more-field" /></div>
        </td>        
    </tr>
    
    <tr>
        <td> </td>
        <td> </td>
    </tr>

    <tr>
        <td> </td>
        <td><input type="submit" value="<?=lang('Create module');?>" /></td>
    </tr>
</table>
<?=form_close();?>

<style type="text/css">
    table.mb {width:940px;}
    table.mb td {vertical-align:top;border-bottom:1px solid #EEEEEE;border-right:1px solid #EEEEEE;padding:3px 0;}
    table.mb input[type=text] {width:200px;border:1px solid #238EC6;padding:2px;}
    .md-b {padding:0;margin: 0;}
    .mb-field {padding:5px 0;}
    #mb-content-field {}
    .mb-remove-field {padding:0 5px;}
    .md-error p {color:#FF0000;font-weight:700;}
    input[type=submit], input[type=button] {border:1px solid #000000;padding:2px 7px;background-color:#EEEEEE;font-weight:700;}
</style>
<script type="text/javascript">
    $(function() {
		$("#mb-add-more-field").livequery('click', function() {
            $("#mb-content-field").append('<div class="mb-field"><input type="text" name="field_name[]" /><a href="javascript:void(0)" class="mb-remove-field">X</a></div>');
        });
        
        $(".mb-remove-field").livequery('click', function () {
            $(this).parent().remove();
        });
	});
</script>